package com.hellobike.haxing.modules.purchase.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.hellobike.haxing.modules.purchase.entity.TPurchaseProRecord;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.Date;
import java.util.List;

/**
 * @Description: t_purchase_pro_record
 * @Author: haxing-boot
 * @Date:   2020-03-04
 * @Version: V1.0
 */
public interface TPurchaseProRecordMapper extends BaseMapper<TPurchaseProRecord> {

    @Select("SELECT sku_id,sku_name,sku_unit,dimension_values,purchase_price,sum(purchase_volume) as purchase_volume,warehouse_name,order_time " +
            "FROM t_purchase_pro_record " +
            "where type = #{type} " +
            "and create_time > #{startTime}" +
            "and create_time <= #{endTime}" +
            "and order_time > #{startTime}" +
            "and order_time <= #{orderEndTime}" +
            "and supplier_id = #{supplierId} " +
            "GROUP BY sku_id,sku_name,sku_unit,dimension_values,purchase_price,warehouse_name,order_time")
    List<TPurchaseProRecord> selectRecords(@Param("startTime") Date startTime, @Param("endTime") Date endTime,@Param("orderEndTime") Date orderEndTime, @Param("supplierId") Long supplierId,@Param("type") Integer type);

}
